#ifndef FORMPEOPLE_H
#define FORMPEOPLE_H

#include <QWidget>
#include "housingdbms.h"
#include "dbmscontainer.h"
#include "modelcontainer.h"

#include <QItemSelectionModel>

namespace Ui {
    class FormPeople;
}

class FormPeople : public QWidget, public DbmsContainer
{
    Q_OBJECT

    TenantsModel *mp_ten_model;
    FamilyModel *mp_fam_model;

    QItemSelectionModel *mp_tenant_sel_model;
    QItemSelectionModel *mp_fam_sel_model;
    QVariant mqv_current_t_index;
    QVariant mqv_current_f_index;

public:
    explicit FormPeople(QWidget *parent = 0);

    inline void set_dbms(HousingDBMS *p_dbms)
    {
         mp_dbms = p_dbms;
         mp_ten_model = dynamic_cast<ModelContainer *>(mp_dbms->get_models())->get_tenant_model();
         mp_fam_model = dynamic_cast<ModelContainer *>(mp_dbms->get_models())->get_family_model();
    }

    void update_models(bool do_not_load = false);
    void update_fam_model();

    void enable_selection();
    void set_tenant_selected(const QVariant &qv_t_index);
    void hide_sel_btn();

     ~FormPeople();
private slots:
    void tenant_selected(const QModelIndex &index);
    void tenant_activated(const QModelIndex &index);
    void new_tenant();
    void del_tenant();

    void fam_member_selected(const QModelIndex &index);
    void fam_member_activated(const QModelIndex &index);
    void new_fam_member();
    void del_fam_member();
    void select_record();
signals:
    void record_selected(QVariant );
private:
    Ui::FormPeople *ui;
};

#endif // FORMPEOPLE_H
